const express = require('express')
const api = require('./api')
const {createjob} = require('./cron')
const app = express()


const http = require('http');
const server = http.createServer(app);
const {Server} = require('socket.io');
const io = new Server(server);

io.on('connection', function (socket) {
    console.log('a user connected');
    createjob(socket);
    socket.on('chat message',(msg)=> {
        console.log('message: ' + msg);
    })

});

server.listen(3000, () => {
    console.log('listening on *:3000');
})

app.get('/',(req, res) => {
   res.sendFile(__dirname + '/index.html');
});

app.get('/get_comment_list/:pageNum', async (req, res) => {
    const commentList = await api.getCommentList(req.params.pageNum);
    console.log(commentList);
    res.send('Hello WorldAA!')
})
